home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / vmcmd / RCS / vmcmd.c,v < prev    next >
Encoding:
Text File  |  1991-03-18  |  10.6 KB  |  487 lines

  1. head     1.9;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.9
  10. date     91.03.18.13.44.52;  author kupfer;  state Exp;
  11. branches ;
  12. next     1.8;
  13.  
  14. 1.8
  15. date     91.03.10.13.43.27;  author kupfer;  state Exp;
  16. branches ;
  17. next     1.7;
  18.  
  19. 1.7
  20. date     91.03.10.11.18.29;  author shirriff;  state Exp;
  21. branches ;
  22. next     1.6;
  23.  
  24. 1.6
  25. date     89.07.31.17.44.49;  author david;  state Exp;
  26. branches ;
  27. next     1.5;
  28.  
  29. 1.5
  30. date     89.01.11.12.20.52;  author mendel;  state Exp;
  31. branches ;
  32. next     1.4;
  33.  
  34. 1.4
  35. date     88.10.20.10.13.40;  author nelson;  state Exp;
  36. branches ;
  37. next     1.3;
  38.  
  39. 1.3
  40. date     88.09.26.11.51.17;  author nelson;  state Exp;
  41. branches ;
  42. next     1.2;
  43.  
  44. 1.2
  45. date     88.09.22.20.59.05;  author nelson;  state Exp;
  46. branches ;
  47. next     1.1;
  48.  
  49. 1.1
  50. date     88.08.16.09.55.23;  author nelson;  state Exp;
  51. branches ;
  52. next     ;
  53.  
  54.  
  55. desc
  56. @@
  57.  
  58.  
  59. 1.9
  60. log
  61. @Change "" to <> for include's.  Check the return status from Vm_Cmd
  62. and exit with an appropriate value.
  63. @
  64. text
  65. @/* 
  66.  * vmcmd.c --
  67.  *
  68.  *    User interface to the Vm_Cmd system call.
  69.  *
  70.  * Copyright (C) 1986 Regents of the University of California
  71.  * All rights reserved.
  72.  */
  73.  
  74. #ifndef lint
  75. static char rcsid[] = "$Header: /sprite/src/cmds/vmcmd/RCS/vmcmd.c,v 1.8 91/03/10 13:43:27 kupfer Exp Locker: kupfer $ SPRITE (Berkeley)";
  76. #endif not lint
  77.  
  78. #include <sprite.h>
  79. #include <cfuncproto.h>
  80. #include <option.h>
  81. #include <vm.h>
  82.  
  83. /*
  84.  * Command line options.
  85.  */
  86. int    maxPageOutProcs = -1;
  87. int    pagesToCheck = -1;
  88. int    clockSleep = -1;
  89. int    canCOW = -1;
  90. int    freeWhenClean = -1;
  91. int    flushSeg = -1;
  92. int    lowPage = -1;
  93. int    highPage = -1;
  94. int    fsPenalty = -1;
  95. Boolean    resetFsMinMax = FALSE;
  96. int    numPageGroups = -1;
  97. int    alwaysRefuse = -1;
  98. int    alwaysSayYes = -1;
  99. int    corReadOnly = -1;
  100. int    useReadAhead = -1;
  101. int    prefetch = -1;
  102. int    tracesPerSecond = -1;
  103. Boolean    endTracing = FALSE;
  104. int    writeablePageout = -1;
  105. int    writeableRefPageout = -1;
  106. int    extra1 = -1;
  107. int    extra2 = 0;
  108. #ifdef spur
  109. int    flushOnRefBitClear = -1;
  110. int    setUseHardRefBit = -1;
  111. int    ownStackAndHeap = -1;
  112. int    uniprocessorFlushPage = -1;
  113. #endif
  114.  
  115. Option optionArray[] = {
  116.     {OPT_INT, "a", (Address)&alwaysRefuse, "\tSet the always refuse flag.\n"},
  117.     {OPT_INT, "A", (Address)&alwaysSayYes, "\tSet the always say yes flag.\n"},
  118.     {OPT_INT, "c", (Address)&pagesToCheck, "\tNumber of pages to check each iteration of the clock algorithm"},
  119.     {OPT_INT, "C", (Address)&canCOW, "\tSet the copy-on-write flag."},
  120.     {OPT_INT, "f", (Address)&freeWhenClean, "\tSet free when clean flag."},
  121.     {OPT_INT, "F", (Address)&fsPenalty,
  122.         "\tPenalty in seconds to make FS pay."},
  123.     {OPT_TRUE, "fsreset", (Address)&resetFsMinMax,
  124.          "\tReset the FS cache minimum and maximum."},
  125.     {OPT_INT, "x", (Address)&flushSeg, "\tSegment to flush."},
  126.     {OPT_INT, "h", (Address)&highPage, "\tHighest page to flush."},
  127.     {OPT_INT, "l", (Address)&lowPage, "\tLowest page to flush."},
  128.     {OPT_INT, "n", (Address)&numPageGroups,
  129.         "\tNumber of groups to divide available pages into.\n"},
  130.     {OPT_INT, "p", (Address)&maxPageOutProcs, "\tMaximum number of page out procs"},
  131.     {OPT_INT, "P", (Address)&prefetch, "\tSet prefetch flag"},
  132.     {OPT_INT, "r", (Address)&corReadOnly, "\tSet copy-on-ref read-only flag"},
  133.     {OPT_INT, "R", (Address)&useReadAhead, "\tSet use fs read ahead flag"},
  134.     {OPT_INT, "s", (Address)&clockSleep, "\tNumber of seconds between iterations of the clock algorithm"},
  135.     {OPT_INT, "t", (Address)&tracesPerSecond, "\tNumber of times to trace per second"},
  136.     {OPT_TRUE, "T", (Address)&endTracing, "\tEnd tracing"},
  137.     {OPT_INT, "w", (Address)&writeablePageout, "\tSet the vm writeable page out flag"},
  138.     {OPT_INT, "W", (Address)&writeableRefPageout, "\tSet the vm writeable ref page out flag"},
  139.     {OPT_INT, "e", (Address)&extra1, "\tDo extra command, with the number specified\n"},
  140.     {OPT_INT, "X", (Address)&extra2, "\tSecond argument for extra command\n"},
  141. #ifdef spur
  142.     {OPT_INT, "z", (Address)&flushOnRefBitClear, "\tSet the flush page on ref bit clear flag\n"},
  143.     {OPT_INT, "Z", (Address)&setUseHardRefBit, "\tSet the use hard ref bit flag\n"},
  144.     {OPT_INT, "o", (Address)&ownStackAndHeap, "\tSet the coherency bit in the pte of stack and heap pages\n"},
  145.     {OPT_INT, "u", (Address)&uniprocessorFlushPage, "\tSet the use uniprocessor page flush flag\n"},
  146. #endif
  147. };
  148. int numOptions = sizeof(optionArray) / sizeof(Option);
  149.  
  150. /* 
  151.  * Forward references:
  152.  */
  153.  
  154. void DoCmd _ARGS_ ((int command, int arg, int *status));
  155.  
  156.  
  157. /*
  158.  *----------------------------------------------------------------------
  159.  *
  160.  * main --
  161.  *
  162.  *    Execute the commands.
  163.  *
  164.  * Results:
  165.  *    None.
  166.  *
  167.  * Side effects:
  168.  *    Calls Vm_Cmd.
  169.  *
  170.  *----------------------------------------------------------------------
  171.  */
  172. main(argc, argv)
  173.     int argc;
  174.     char *argv[];
  175. {
  176.     int status = 0;        /* our exit status */
  177.  
  178.     (void)Opt_Parse(argc, argv, optionArray, numOptions, 0);
  179.     if (flushSeg != -1)  {
  180.     int    arr[3];
  181.     arr[0] = flushSeg;
  182.     arr[1] = lowPage;
  183.     arr[2] = highPage;
  184.     DoCmd(VM_FLUSH_SEGMENT, arr, &status);
  185.     }
  186.     if (freeWhenClean != -1) {
  187.     DoCmd(VM_SET_FREE_WHEN_CLEAN, freeWhenClean, &status);
  188.     }
  189.     if (maxPageOutProcs != -1) {
  190.     DoCmd(VM_SET_PAGEOUT_PROCS, maxPageOutProcs, &status);
  191.     }
  192.     if (pagesToCheck != -1) {
  193.     DoCmd(VM_SET_CLOCK_PAGES, pagesToCheck, &status);
  194.     }
  195.     if (clockSleep != -1) { 
  196.     DoCmd(VM_SET_CLOCK_INTERVAL, clockSleep, &status);
  197.     }
  198.     if (canCOW != -1) {
  199.     DoCmd(VM_SET_COW, canCOW, &status);
  200.     }
  201.     if (fsPenalty != -1) {
  202.     DoCmd(VM_SET_FS_PENALTY, fsPenalty, &status);
  203.     }
  204.     if (resetFsMinMax) {
  205.     DoCmd(VM_RESET_FS_STATS, 0, &status);
  206.     }
  207.     if (numPageGroups != -1) {
  208.     DoCmd(VM_SET_NUM_PAGE_GROUPS, numPageGroups, &status);
  209.     }
  210.     if (alwaysRefuse != -1) {
  211.     DoCmd(VM_SET_ALWAYS_REFUSE, alwaysRefuse, &status);
  212.     }
  213.     if (alwaysSayYes != -1) {
  214.     DoCmd(VM_SET_ALWAYS_SAY_YES, alwaysSayYes, &status);
  215.     }
  216.     if (corReadOnly != -1) {
  217.     DoCmd(VM_SET_COR_READ_ONLY, corReadOnly, &status);
  218.     }
  219.     if (useReadAhead != -1) {
  220.     DoCmd(VM_SET_USE_FS_READ_AHEAD, useReadAhead, &status);
  221.     }
  222.     if (prefetch != -1) {
  223.     DoCmd(VM_SET_PREFETCH, prefetch, &status);
  224.     }
  225.     if (tracesPerSecond != -1) {
  226.     DoCmd(VM_START_TRACING, tracesPerSecond, &status);
  227.     }
  228.     if (endTracing) {
  229.     DoCmd(VM_END_TRACING, 0, &status);
  230.     }
  231.     if (writeablePageout != -1) {
  232.     DoCmd(VM_SET_WRITEABLE_PAGEOUT, writeablePageout, &status);
  233.     }
  234.     if (writeableRefPageout != -1) {
  235.     DoCmd(VM_SET_WRITEABLE_REF_PAGEOUT, writeableRefPageout, &status);
  236.     }
  237.     if (extra1 != -1) {
  238.     DoCmd(extra1, extra2, &status);
  239.     }
  240. #ifdef spur
  241.     if (flushOnRefBitClear != -1) {
  242.     DoCmd(VM_SET_FLUSH_ON_REF_BIT_CLEAR, flushOnRefBitClear, &status);
  243.     }
  244.     if (setUseHardRefBit != -1) {
  245.     DoCmd(VM_SET_USE_HARD_REF_BIT, setUseHardRefBit, &status);
  246.     }
  247.     if (ownStackAndHeap != -1) {
  248.     DoCmd(VM_SET_COHERENCY_BIT, ownStackAndHeap, &status);
  249.     }
  250.     if (uniprocessorFlushPage != -1) {
  251.     DoCmd(VM_SET_UP_FLUSH_PAGE, uniprocessorFlushPage, &status);
  252.     }
  253. #endif
  254.  
  255.     exit(status);
  256. }
  257.  
  258.  
  259. /*
  260.  *----------------------------------------------------------------------
  261.  *
  262.  * DoCmd --
  263.  *
  264.  *    Call Vm_Cmd and check for errors.
  265.  *
  266.  * Results:
  267.  *    Sets *statusPtr to non-zero if there was an error.
  268.  *
  269.  * Side effects:
  270.  *    None.
  271.  *
  272.  *----------------------------------------------------------------------
  273.  */
  274.  
  275. void
  276. DoCmd(cmd, arg, statusPtr)
  277.     int cmd;            /* argument to Vm_Cmd */
  278.     int arg;            /* ditto */
  279.     int *statusPtr;        /* program's exit status (out) */
  280. {
  281.     if (Vm_Cmd(cmd, arg) != SUCCESS) {
  282.     *statusPtr = 1;
  283.     }
  284. }
  285. @
  286.  
  287.  
  288. 1.8
  289. log
  290. @Add -fsreset command.
  291. @
  292. text
  293. @d11 1
  294. a11 1
  295. static char rcsid[] = "$Header: /sprite/src/cmds/vmcmd/RCS/vmcmd.c,v 1.7 91/03/10 11:18:29 shirriff Exp Locker: kupfer $ SPRITE (Berkeley)";
  296. d14 4
  297. a17 2
  298. #include "option.h"
  299. #include "vm.h"
  300. d86 6
  301. d112 2
  302. d120 1
  303. a120 1
  304.     (void) Vm_Cmd(VM_FLUSH_SEGMENT, arr);
  305. d123 1
  306. a123 1
  307.     (void) Vm_Cmd(VM_SET_FREE_WHEN_CLEAN, freeWhenClean);
  308. d126 1
  309. a126 1
  310.     (void) Vm_Cmd(VM_SET_PAGEOUT_PROCS, maxPageOutProcs);
  311. d129 1
  312. a129 1
  313.     (void) Vm_Cmd(VM_SET_CLOCK_PAGES, pagesToCheck);
  314. d132 1
  315. a132 1
  316.     (void) Vm_Cmd(VM_SET_CLOCK_INTERVAL, clockSleep);
  317. d135 1
  318. a135 1
  319.     (void) Vm_Cmd(VM_SET_COW, canCOW);
  320. d138 1
  321. a138 1
  322.     (void) Vm_Cmd(VM_SET_FS_PENALTY, fsPenalty);
  323. d141 1
  324. a141 1
  325.     (void) Vm_Cmd(VM_RESET_FS_STATS, 0);
  326. d144 1
  327. a144 1
  328.     (void) Vm_Cmd(VM_SET_NUM_PAGE_GROUPS, numPageGroups);
  329. d147 1
  330. a147 1
  331.     (void) Vm_Cmd(VM_SET_ALWAYS_REFUSE, alwaysRefuse);
  332. d150 1
  333. a150 1
  334.     (void) Vm_Cmd(VM_SET_ALWAYS_SAY_YES, alwaysSayYes);
  335. d153 1
  336. a153 1
  337.     (void) Vm_Cmd(VM_SET_COR_READ_ONLY, corReadOnly);
  338. d156 1
  339. a156 1
  340.     (void) Vm_Cmd(VM_SET_USE_FS_READ_AHEAD, useReadAhead);
  341. d159 1
  342. a159 1
  343.     (void) Vm_Cmd(VM_SET_PREFETCH, prefetch);
  344. d162 1
  345. a162 1
  346.     (void) Vm_Cmd(VM_START_TRACING, tracesPerSecond);
  347. d165 1
  348. a165 1
  349.     (void) Vm_Cmd(VM_END_TRACING, 0);
  350. d168 1
  351. a168 1
  352.     (void) Vm_Cmd(VM_SET_WRITEABLE_PAGEOUT, writeablePageout);
  353. d171 1
  354. a171 1
  355.     (void) Vm_Cmd(VM_SET_WRITEABLE_REF_PAGEOUT, writeableRefPageout);
  356. d174 1
  357. a174 1
  358.     (void) Vm_Cmd(extra1, extra2);
  359. d178 1
  360. a178 1
  361.     (void) Vm_Cmd(VM_SET_FLUSH_ON_REF_BIT_CLEAR, flushOnRefBitClear);
  362. d181 1
  363. a181 1
  364.     (void) Vm_Cmd(VM_SET_USE_HARD_REF_BIT, setUseHardRefBit);
  365. d184 1
  366. a184 1
  367.     (void) Vm_Cmd(VM_SET_COHERENCY_BIT, ownStackAndHeap);
  368. d187 1
  369. a187 1
  370.     (void) Vm_Cmd(VM_SET_UP_FLUSH_PAGE, uniprocessorFlushPage);
  371. d190 30
  372. @
  373.  
  374.  
  375. 1.7
  376. log
  377. @Added -e,-X flags.
  378. @
  379. text
  380. @d11 1
  381. a11 1
  382. static char rcsid[] = "$Header: /sprite/src/cmds/vmcmd/RCS/vmcmd.c,v 1.6 89/07/31 17:44:49 david Exp Locker: shirriff $ SPRITE (Berkeley)";
  383. d29 1
  384. d56 3
  385. a58 1
  386.         "\tPenalty in seconds to make FS pay.\n"},
  387. d129 3
  388. @
  389.  
  390.  
  391. 1.6
  392. log
  393. @Added the uniprocessorFlushPage option for spur.
  394. @
  395. text
  396. @d11 1
  397. a11 1
  398. static char rcsid[] = "$Header: /a/newcmds/vmcmd/RCS/vmcmd.c,v 1.5 89/01/11 12:20:52 mendel Exp Locker: david $ SPRITE (Berkeley)";
  399. d39 2
  400. d70 2
  401. d156 3
  402. @
  403.  
  404.  
  405. 1.5
  406. log
  407. @Added ownStackAndHeap command for spur.
  408. @
  409. text
  410. @d11 1
  411. a11 1
  412. static char rcsid[] = "$Header: vmcmd.c,v 1.3 88/09/26 11:51:17 nelson Exp $ SPRITE (Berkeley)";
  413. d39 1
  414. a39 1
  415. #ifdef SPUR
  416. d43 1
  417. d68 1
  418. a68 1
  419. #ifdef SPUR
  420. d72 1
  421. d153 1
  422. a153 1
  423. #ifdef SPUR
  424. d162 3
  425. @
  426.  
  427.  
  428. 1.4
  429. log
  430. @Added flags for David Wood so that he could force heap and stack
  431. pages to always be modified.
  432. @
  433. text
  434. @d42 1
  435. d70 1
  436. d157 3
  437. @
  438.  
  439.  
  440. 1.3
  441. log
  442. @Added spur dependent flags.
  443. @
  444. text
  445. @d11 1
  446. a11 1
  447. static char rcsid[] = "$Header: vmcmd.c,v 1.2 88/09/22 20:59:05 nelson Exp $ SPRITE (Berkeley)";
  448. d37 2
  449. d64 2
  450. d142 6
  451. @
  452.  
  453.  
  454. 1.2
  455. log
  456. @Removed extraneous commands.
  457. @
  458. text
  459. @d11 1
  460. a11 1
  461. static char rcsid[] = "$Header: vmcmd.c,v 1.1 88/08/16 09:55:23 nelson Exp $ SPRITE (Berkeley)";
  462. d37 4
  463. d62 4
  464. d139 8
  465. @
  466.  
  467.  
  468. 1.1
  469. log
  470. @Initial revision
  471. @
  472. text
  473. @d11 1
  474. a11 1
  475. static char rcsid[] = "$Header: vmCmd.c,v 1.8 88/06/20 16:47:19 nelson Exp $ SPRITE (Berkeley)";
  476. a22 2
  477. int    forceRef = -1;
  478. int    forceSwap = -1;
  479. a99 6
  480.     }
  481.     if (forceRef != -1) {
  482.     (void) Vm_Cmd(VM_FORCE_REF, forceRef);
  483.     }
  484.     if (forceSwap != -1) {
  485.     (void) Vm_Cmd(VM_FORCE_SWAP, forceSwap);
  486. @
  487.